﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Go.Tools;
using Go.Model;
using Go;
using System.Drawing;
using System.Windows.Forms;
using tpGo;


namespace tpGo
{
    class Intersection : IObserver
    {
        private Coordinate _coordinate;
        private Tablero aTablero;
        private Go.Tools.Color color;
        private Boolean isBussy;

        public Boolean IsBussy
        {
            get { return isBussy; }
        }


        public Intersection(Coordinate aCoordinate, Tablero tablero)
        {
            _coordinate = aCoordinate;
            aTablero = tablero;
            isBussy = false;
        }

        public void draw()
        {
            Point pto = Functions.centrarImagen(new Point(_coordinate.x, _coordinate.y), ImageConstants.FIGUREHEIGHT, ImageConstants.FIGUREHEIGHT);
            if (Go.Tools.Color.White == color)
                aTablero.Draw(ImageConstants.IMAGEWHITESTONE, ImageConstants.FIGUREHEIGHT, ImageConstants.FIGUREHEIGHT, pto); 
            else
                aTablero.Draw(ImageConstants.IMAGEBLACKSTONE, ImageConstants.FIGUREHEIGHT, ImageConstants.FIGUREHEIGHT, pto); 
        }

        //Propiedades 
        public int Y
        {
            get { return _coordinate.y; }
        }
        public int X
        {
            get { return _coordinate.x; }
        }

        public Coordinate Coordinate
        {
            get { return _coordinate; }
            set { _coordinate = value; }
        }

        public void Update(Object sender)
        {
            color = ((Position)sender).Group.Color;
            isBussy = true;
            draw();
        
        }

    }
}